package servlet;

import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.simple.JSONObject;

import model.AddMasterImpl;
import model.AddUserImpl;
import model.AssignUserImpl;
import model.PollUserImpl;
import bean.PollUser;
import java.sql.Date;

public class AssignUserServlet extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost (request, response);
	}
	
	public void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html");
		response.setCharacterEncoding("GBK");
		System.out.println("here");
		String username = request.getParameter("username");
		String listid = request.getParameter("listid");
		String[] spl = listid.split(",");
		String listname = spl[1];
		listid = spl[0];
		String masterUsername = request.getParameter("masterUsername");
		//String listid, String isTemplate, String listname, String masterUsername, String user
		System.out.println("Username:"+username);

		AssignUserImpl impl = new AssignUserImpl(listid, "N", listname, masterUsername, username);
		
		response.sendRedirect("pmAssignUser.jsp");
	}
}
